var e = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../dist/dialog/dialog")), t = getApp();

Page({
    data: {
        orderId: null,
        storeName: "",
        uploadUrl: "upload.uploadPic",
        fileList: [],
        evaluateType: 3,
        type: 1,
        comment: "",
        images: [],
        recommendList: [ {
            image: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/recommend.png",
            onImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/recommend-on.png",
            name: "推荐",
            type: 3
        }, {
            image: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/ordinary.png",
            onImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/ordinary-on.png",
            name: "一般",
            type: 2
        }, {
            image: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/not-recommend.png",
            onImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/not-recommend-on.png",
            name: "不推荐",
            type: 1
        } ]
    },
    onLoad: function(e) {
        var t;
        "" !== (null !== (t = e.orderId) && void 0 !== t ? t : "") && this.setData({
            orderId: parseInt(e.orderId),
            type: parseInt(e.type),
            storeName: e.storeName
        });
    },
    initData: function() {
        this.setData({
            orderId: null,
            evaluateType: 1,
            comment: "",
            images: []
        });
    },
    onanotherPics: function() {
        var e = this;
        wx.chooseImage({
            count: 9,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(t) {
                e.unload({
                    tempFilePaths: t.tempFilePaths
                }, "2");
            }
        });
    },
    unload: function(e, o) {
        console.log(o);
        var n = t.getNetAddresss(this.data.uploadUrl), a = this, i = e.i ? e.i : 0, s = e.success ? e.success : 0, u = e.fail ? e.fail : 0;
        wx.uploadFile({
            url: n,
            filePath: e.tempFilePaths[i],
            name: "file",
            formData: null,
            success: function(e) {
                var t = JSON.parse(e.data);
                console.log(t.data.img_url), ("1" == o || 2 == o) && (a.data.fileList.push(t.data.img_url), 
                a.setData({
                    images: a.data.fileList
                })), console.log(a.data.fileList);
            },
            fail: function(e) {
                u++;
            },
            complete: function(t) {
                ++i == e.tempFilePaths.length || (e.i = i, e.success = s, e.fail = u, a.unload(e, o));
            }
        });
    },
    evaluateText: function(e) {
        this.setData({
            comment: e.detail.value
        });
    },
    onRecommend: function(e) {
        var t = e.currentTarget.dataset.type;
        this.setData({
            evaluateType: t
        });
    },
    evaluateForm: function() {
        var o = this, n = t.getNetAddresss("plugin.coupon-store.frontend.comment.comment"), a = {
            order_id: this.data.orderId,
            comment_type: this.data.evaluateType,
            comment: this.data.comment,
            images: this.data.images
        };
        t._postNetWork({
            url: n,
            data: a,
            success: function(t) {
                var n = t.data;
                1 == n.result ? e.default.alert({
                    message: n.msg
                }).then(function() {
                    o.initData();
                    var e = getCurrentPages(), t = e[e.length - 2];
                    1 === o.data.type ? t.storeorderDetails() : t.storeGoodsList(), setTimeout(function(e) {
                        wx.navigateBack({
                            delta: 1
                        }, 1e3);
                    });
                }) : wx.showToast({
                    icon: "none",
                    title: n.msg,
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});